#ifndef UTILS_H
#define UTILS_H

#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <cstdlib>
#include "hashlib++/hl_hashwrapper.h"
#include "hashlib++/hl_md5wrapper.h"

namespace utils
{
using namespace std;

// breaks apart a string into substrings separated by a character string
// does not use a strtok() style list of separator characters
// returns a vector of std::strings
vector<string> explode (const string &inString,const string &separator);

//转换为string类型
template <class T> string toString(const T& a)
{
    ostringstream ost;
    ost << a;
    return ost.str();
}

// string conversion from string to typename T with a flag
// the represents success or failure.
// e.g: int d = FromString<int>( s );
template<typename T>T fromString( const std::string& s)
{
    std::istringstream is(s);
    T t;
    is >> t;
    return t;
}
//string md5(const string&);
string zotero_path_decode(const string&);
string escapeSQL(const string& str);
string replace(const string& str, const char f, const char t);
string random_zotero_key(int len,string base);
string random_zotero_key(int len=8);
string get_data_dir();
};
#endif
